def is_connected(g, s, t):
    visited = [False] * g.get_v_num()

    def dfs(source):
        if source.val == t.val:
            return True
        visited[source.val] = True
        for adj in source.get_adj():
            if not visited[adj.val]:
                res = dfs(adj)
                if res:
                    return res
        return False

    return dfs(s)


from instance import Graph1

graph1 = Graph1()
ans = is_connected(graph1.graph1, graph1.v0, graph1.v5)
print(ans)
